<?php

namespace app\admin\model;

use think\Model;

class CurrencyConcern extends Model
{
    // 表名
    protected $name = 'currency_concern';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'status_text'
    ];
    

    
    public function getStatusList()
    {
        return ['1' => __('关注'),'2' => __('取消关注')];
    }     


    public function getStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function currency()
    {
        return $this->belongsTo('Currency', 'currency_id', 'currency_id', [], 'LEFT')->setEagerlyType(0);
    }


    public function member()
    {
        return $this->belongsTo('Member', 'member_id', 'member_id', [], 'LEFT')->setEagerlyType(0);
    }
}
